home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 47
/
Amiga Format AFCD47 (Issue 131, Xmas 1999).iso
/
-serious-
/
misc
/
textdisplay
/
textdisplay.h
< prev
next >
Wrap
C/C++ Source or Header
|
1999-10-11
|
6KB
|
207 lines
#ifndef TEXTDISPLAY_H
#define TEXTDISPLAY_H
/*********************************************************
** **
** TextDisplay MUI Class **
** **
** ©1998-1999 Simone Tellini **
** **
*********************************************************/
/// Support stuff
#ifndef REG
#ifdef _DCC
#define REG(x) __ ## x
#else
#define REG(x) register __ ## x
#endif
#endif
#ifndef ASM
#if defined __MAXON__ || defined __STORM__ || defined _DCC
#define ASM
#else
#define ASM __asm
#endif
#endif
#ifndef SAVEDS
#ifdef __MAXON__
#define SAVEDS
#endif
#if defined __STORM__ || defined __SASC
#define SAVEDS __saveds
#endif
#if defined _GCC || defined _DCC
#define SAVEDS __geta4
#endif
#endif
#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
#endif
#ifndef TAGBASE
#define TAGBASE ( TAG_USER | 0x776B0000 )
#endif
#ifndef MIN
#define MIN(a,b) (( a < b ) ? ( a ) : ( b ))
#endif
#ifndef MAX
#define MAX(a,b) (( a > b ) ? ( a ) : ( b ))
#endif
#ifndef ABS
#define ABS(a) (((a) > 0) ? (a) : -(a))
#endif
///
/// Externs
ULONG SAVEDS ASM TextDisplay_Dispatcher( REG( a0 ) struct IClass *, REG( a2 ) Object *, REG( a1 ) Msg );
ULONG SAVEDS ASM TextDisplayScroll_Dispatcher( REG( a0 ) struct IClass *, REG( a2 ) Object *, REG( a1 ) Msg );
extern struct MUI_CustomClass *CL_TextDisplay;
extern struct MUI_CustomClass *CL_TextDisplayScroll;
///
#define TextDisplayObject NewObject( CL_TextDisplayScroll->mcc_Class, 0
/*************************
** Methods **
*************************/
#define MUIM_TextDisplay_LoadFile (TAGBASE + 1)
#define MUIM_TextDisplay_Flush (TAGBASE + 2)
#define MUIM_TextDisplay_Scroll (TAGBASE + 3)
#define MUIM_TextDisplay_CopyToClip (TAGBASE + 4)
#define MUIM_TextDisplay_SetMark (TAGBASE + 5)
#define MUIM_TextDisplay_RedrawLine (TAGBASE + 6)
/*************************
** Attributes **
*************************/
#define MUIA_TextDisplay_Scroller (TAGBASE + 1) /* PRIVATE i... Object * */
#define MUIA_TextDisplay_FirstLine (TAGBASE + 2) /* .sgn ULONG */
#define MUIA_TextDisplay_NumLines (TAGBASE + 3) /* ..g. ULONG */
#define MUIA_TextDisplay_Size (TAGBASE + 4) /* ..g. ULONG */
#define MUIA_TextDisplay_Lines (TAGBASE + 5) /* ..g. struct MinList * */
#define MUIA_TextDisplay_TextPen (TAGBASE + 6) /* isg. APTR */
#define MUIA_TextDisplay_BackPen (TAGBASE + 7) /* isg. APTR */
#define MUIA_TextDisplay_MarkPen (TAGBASE + 8) /* isg. APTR */
#define MUIA_TextDisplay_ClipUnit (TAGBASE + 9) /* isg. UBYTE */
#define MUIA_TextDisplay_AutoCopy (TAGBASE + 10) /* isg. BOOL */
#define MUIA_TextDisplay_HideMark (TAGBASE + 11) /* isg. BOOL */
#define MUIA_TextDisplay_Contents (TAGBASE + 12) /* .sg. STRPTR */
#define MUIA_TextDisplay_UseWinBorder (TAGBASE + 13) /* i... BOOL */
#define MUIA_TextDisplay_TabSize (TAGBASE + 14) /* i.g. UWORD */
/*************************
** Values **
*************************/
#define MUIV_TextDisplay_Scroll_PageDown -1
#define MUIV_TextDisplay_Scroll_PageUp -2
#define MUIV_TextDisplay_Scroll_Top 0
#define MUIV_TextDisplay_Scroll_Bottom -3
/*************************
** Structures **
*************************/
struct TextDisplayScrollData {
Object *Display;
};
struct DispLine {
STRPTR Line;
ULONG Length;
};
#define CHUNK_SIZE 100
struct LinesChunk {
struct LinesChunk *Succ;
struct LinesChunk *Pred;
struct DispLine Lines[ CHUNK_SIZE ];
};
struct TextDisplayData {
Object *Scroller;
struct IClass *Notify;
UBYTE *Buffer;
ULONG Size;
APTR Pool;
struct MinList Lines;
ULONG NumLines;
ULONG DisplayedLines;
ULONG First; // first line showed
ULONG Flags;
ULONG XOffset;
ULONG YOffset;
ULONG StartX;
LONG Direction; // for scrolling
ULONG OldWidth;
UBYTE TextPen;
UBYTE BackPen;
UBYTE MarkPen;
UBYTE Clipboard; // clipboard unit
UWORD TabSize;
APTR TextPenSpec;
APTR BackPenSpec;
APTR MarkPenSpec;
ULONG MarkLineStart;
ULONG MarkLineEnd;
UWORD MarkColStart;
UWORD MarkColEnd;
ULONG RedrawLine;
};
#define TD_GO_UP (1 << 0)
#define TD_GO_DOWN (1 << 1)
#define TD_WORDWRAP (1 << 2)
#define TD_MARK (1 << 3)
#define TD_MARKED (1 << 4)
#define TD_REDRAWLINE (1 << 5)
#define TD_CLEARMARK (1 << 6)
#define TD_AUTOCOPY (1 << 7)
#define TD_HIDEMARK (1 << 8)
#define TD_DONTFREE (1 << 9)
#define TD_NEWTEXTPEN (1 << 10)
#define TD_NEWBACKPEN (1 << 11)
#define TD_NEWMARKPEN (1 << 12)
#define TD_DISPOSING (1 << 13)
#define TD_PREFSMASK ( TD_AUTOCOPY | TD_HIDEMARK )
struct MUIP_TextDisplay_LoadFile {
ULONG MethodID;
STRPTR FileName;
};
struct MUIP_TextDisplay_Scroll {
ULONG MethodID;
ULONG FirstLine;
};
struct MUIP_TextDisplay_RedrawLine {
ULONG MethodID;
ULONG Line;
};
struct MUIP_TextDisplay_SetMark {
ULONG MethodID;
ULONG LineStart;
ULONG LineEnd;
ULONG ColStart;
ULONG ColEnd;
};
#endif /* TEXTDISPLAY_H */